
//点击加载更多
$(function(){
	$.loadmore.get(getData, {scroll: true});
})



/* 加载更多 */
function getData(config){
	/*config.isAjax = true;*/
	var pageNum = $('#pageNum').val();
	
	$.ajax({
		type : "GET",
		dataType : "html",
		url : "/eshop/banner/bannerMoreList.htm",
		data : {
			'pageNo' : pageNum
		},
		success: function(reponse){
			if(Boolean(reponse.trim())){
				pageNum ++;
				$('#pageNum').val(pageNum);
				$(".listWrap").append(reponse);
				$(".clickmore").html('加载更多');
			}else{
				$(".clickmore").html('没有更多数据了');
			}
			
			/*config.isAjax = false;*/
			//to do something....
			
			/******************隐藏more*************************/
			/*if ( (offset + size) >= sum){
				$(".clickmore").hide();
				//停止滚动加载请求
				config.isEnd = true; 
			}else{
				$(".clickmore").show();
			}*/
		},
		error: function(xhr, type){
			console.log('Ajax error!');
		}
	});
}

var eshopBannerStatus = $('#eshopBannerStatus').val();//1:展示下架,0:展示上架


$('.btnBoth').on('click',function(){
	var bannerId = $(this).parent().find('#bannerId').val();
	var	status = null;
	if(eshopBannerStatus == 1){
		$(this).html('上架');
		eshopBannerStatus = 0;
		status = 0;
	}else{
			status = 1;
			eshopBannerStatus = 1;
		$(this).html('下架');
	}
	$.ajax({
		type : "post",
		dataType : "json",
		url : "/eshop/banner/modifyBnnerAction",
		data : {
			'eshopBannerId' : bannerId,
			'status' : status
				
			
		},
		success: function(reponse){
			//success
		},
		error: function(xhr, type){
			//error
		}
	});
})

//点击删除当前列表项
$('.deleteRight').find('.deleteThisList').on('click',function(){
	var bannerId = $(this).parent().parent().find('#bannerId').val();
	var obj = $(this);
	$.ajax({
		type : "post",
		dataType : "json",
		url : "/eshop/banner/modifyBnnerAction",
		data : {
			'eshopBannerId' : bannerId,
			'status' : -8
		},
		success: function(data){
			if(data['code'] == '200'){
				obj.parent().parent().remove();
			}
		},
		error: function(xhr, type){
		
		}
	});
})
